package com.sh.动态规划;

import java.lang.management.ManagementFactory;
import java.util.Arrays;

/**
 * @Auther: sh
 * @Version 1.0
 * @Description:
 */
public class 最长递增子序列 {
    public static void main(String[] args) {

        int[] ints = {10, 9, 2, 5, 3, 7, 101, 18};
        System.out.println(ints.length);
    }

    public static int lengthOfLIS(int[] nums) {
        int length = nums.length;
        // dp数组含义
        int[] ints = new int[length];   // 以第i个结尾的的递增子序列的长度
        Arrays.fill(ints, 1);
        int res = 1;
        for (int i = 1; i < nums.length; i++) {
            for (int j = 0; j < i; j++) {
                if (nums[j] < nums[i]) {
                    ints[i] = Math.max(ints[j] + 1, ints[i]);
                }
            }
            res = Math.max(res, ints[i]); // 移出内层循环
        }
        return res;
    }

}

